package com.edu.exam.entity.assessment.technical;

import com.edu.exam.enums.assessment.technical.QuestionScopeType;
import com.edu.exam.enums.assessment.technical.QuestionStatType;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 试卷查重统计实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：question_check_statistics
 *
 * 根据B-03-10试卷查重子模块设计文档实现
 * 存储试卷查重的统计数据，支持多维度的统计分析。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class QuestionCheckStatistics {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 统计日期
     */
    @Column(name = "stat_date", nullable = false)
    private LocalDate statDate;

    /**
     * 统计类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "stat_type", nullable = false, length = 20)
    private QuestionStatType statType;

    /**
     * 统计范围类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "scope_type", nullable = false, length = 20)
    private QuestionScopeType scopeType;

    /**
     * 统计范围ID
     */
    @Column(name = "scope_id")
    private Long scopeId;

    /**
     * 统计范围名称
     */
    @Column(name = "scope_name", length = 100)
    private String scopeName;

    /**
     * 总查重次数
     */
    @Column(name = "total_checks")
    private Integer totalChecks;

    /**
     * 成功查重次数
     */
    @Column(name = "successful_checks")
    private Integer successfulChecks;

    /**
     * 失败查重次数
     */
    @Column(name = "failed_checks")
    private Integer failedChecks;

    /**
     * 平均相似度
     */
    @Column(name = "avg_similarity", precision = 5, scale = 4)
    private Double avgSimilarity;

    /**
     * 最高相似度
     */
    @Column(name = "max_similarity", precision = 5, scale = 4)
    private Double maxSimilarity;

    /**
     * 最低相似度
     */
    @Column(name = "min_similarity", precision = 5, scale = 4)
    private Double minSimilarity;

    /**
     * 高度相似试卷数
     */
    @Column(name = "highly_similar_count")
    private Integer highlySimilarCount;

    /**
     * 中度相似试卷数
     */
    @Column(name = "moderately_similar_count")
    private Integer moderatelySimilarCount;

    /**
     * 低度相似试卷数
     */
    @Column(name = "low_similarity_count")
    private Integer lowSimilarityCount;

    /**
     * 不相似试卷数
     */
    @Column(name = "not_similar_count")
    private Integer notSimilarCount;

    /**
     * 平均分析耗时
     */
    @Column(name = "avg_analysis_time")
    private Long avgAnalysisTime;

    /**
     * 总检查试卷数
     */
    @Column(name = "total_papers_checked")
    private Integer totalPapersChecked;

    /**
     * 唯一检查试卷数
     */
    @Column(name = "unique_papers_checked")
    private Integer uniquePapersChecked;

    /**
     * 创建批量任务数
     */
    @Column(name = "batch_tasks_created")
    private Integer batchTasksCreated;

    /**
     * 完成批量任务数
     */
    @Column(name = "batch_tasks_completed")
    private Integer batchTasksCompleted;

    /**
     * 实时查重次数
     */
    @Column(name = "real_time_checks")
    private Integer realTimeChecks;

    /**
     * 审核查重次数
     */
    @Column(name = "review_checks")
    private Integer reviewChecks;

    /**
     * 批量查重次数
     */
    @Column(name = "batch_checks")
    private Integer batchChecks;

    /**
     * 同课程查重次数
     */
    @Column(name = "same_course_checks")
    private Integer sameCourseChecks;

    /**
     * 同科目查重次数
     */
    @Column(name = "same_subject_checks")
    private Integer sameSubjectChecks;

    /**
     * 全部试卷查重次数
     */
    @Column(name = "all_papers_checks")
    private Integer allPapersChecks;

    /**
     * 详细统计数据（JSON格式存储）
     */
    @Column(name = "stat_details", columnDefinition = "TEXT")
    private String statDetails;

    /**
     * 统计计算时间
     */
    @Column(name = "calculation_time")
    private Long calculationTime;

    /**
     * 数据来源
     */
    @Column(name = "data_source", length = 50)
    private String dataSource;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 删除标记
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

  }